package cn.knet.sp.ncrm.modules.sys.security.cas.service;

import org.apache.shiro.session.Session;

import java.util.Collection;

import javax.annotation.Resource;

import cn.knet.sp.ncrm.common.security.shiro.session.SessionDAO;


/**
 * @INFO:
 * @Author: Feng Yapeng
 * @Time: 2015/5/14 11:24
 */
public class LogoutJmsListenerService {

	@Resource
	private SessionDAO sessionDAO;


	public void logout(String ticket) {
		Collection<Session> sessions = sessionDAO.getActiveSessions(true);
		for(Session session:sessions){
			String storageTicket= (String) session.getAttribute("ticket");// 请参照CasFilter
			if(ticket!=null && ticket.equals(storageTicket)){
				sessionDAO.delete(session);
				break;
			}

		}

	}


}
